package test.com.sky.jmx.tomcatUtil;

import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.lang.management.ManagementFactory;

import com.sun.jdmk.comm.HtmlAdaptorServer;

/**
 * 需要下载 jmx 拓展包才能运行;
 */
public class TomcatMonitor {

    public static void main(String[] args) throws Exception {
        MBeanServer mbServer = ManagementFactory.getPlatformMBeanServer();
        TomcatUtilMBean tomcatUtil = new TomcatUtil();
        mbServer.registerMBean(tomcatUtil, new ObjectName("myMBean:name = tomcatUtil"));
        HtmlAdaptorServer adaptor = new HtmlAdaptorServer();
        adaptor.setPort(8888);
        mbServer.registerMBean(adaptor, new ObjectName("myMBean:name = htmlAdaptor,port = 8888"));
        adaptor.start();
    }
}
